<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="jquery/jquery1.9/jquery-1.9.0.js"></script>
    <script>
        $(function(){
            // $("div:nth-child(2)").css("background","red");
            // $("div:first-of-type").css("background","red");
            // $("h2:first-child").css("background","red");
            // $("h2:nth-child(1)").css("background","red");
            $("span:nth-child(2)").css("background","green");
        });
    </script>
    <style>

        /* 同类型,同级别中第一个 */
        /* div:first-of-type{
            color:red;
        } */

        /* div作为body的第二个子元素 */
        /* div:nth-child(2){
            background:red;
        } */
    </style>
</head>
<body>

    <h2>h2</h2>
    <div>div1</div>
    <div>div2</div>
    <div>div3</div>
    <span>span0</span>
    <div>
        <span>span1</span>
        <span>span2</span>
    </div>
</body>
</html>